fix(api): cap per_page at 100 and fill open-ended date ranges#884
Merged
Conversation
Two bugs caused 400 Bad Request errors from the Sentry API: 1. listTransactions/listSpans passed --limit directly as per_page. Values >100 were rejected by the API. Now caps at API_MAX_PER_PAGE and auto-paginates when limit exceeds 100, matching the queryEvents pattern in discover.ts. (CLI-F3, CLI-10) 2. timeRangeToApiParams returned only start or only end for open-ended absolute ranges (e.g. --period '>=2024-01-01'). The API requires both. Now fills end=now for start-only, start=end-90d for end-only. Fixes all consumers (traces, spans, explore). (CLI-10)
Contributor
|
Contributor
Codecov Results 📊✅ 6377 passed | Total: 6377 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 84.78%. Project has 13168 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 76.03% 75.89% -0.14%
==========================================
Files 294 294 —
Lines 54404 54606 +202
Branches 0 0 —
==========================================
+ Hits 41362 41438 +76
- Misses 13042 13168 +126
- Partials 0 0 —Generated by Codecov Action |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit df9a978. Configure here.
Extract the duplicated multi-page pagination loop from listTransactions, listSpans, and queryEvents into a generic autoPaginate<T>() helper in infrastructure.ts. This addresses Cursor Bugbot's feedback about code duplication across the three call sites. Also adds comprehensive tests for listTransactions and listSpans (26 tests covering URL construction, per_page capping, auto-pagination, trimming, sort, project handling, and cursor passthrough) to push patch coverage above 80%.
BYK
added a commit
that referenced
this pull request
Apr 30, 2026
…sages (CLI-1J8) (#893) ## Summary - Widen `enrichDashboardError` to handle 400 on `create` (not just `update`), so plan-limit messages like *"You may not exceed 10 dashboards on your current plan."* surface clearly instead of a raw `ApiError: Failed to create dashboard: 400 Bad Request` - Add test for 400 on create with plan-limit detail Fixes CLI-1J8. **Note:** CLI-1JD (explore 400 from open-ended time ranges) was already fixed in #884.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes two bugs causing 400 Bad Request errors from the Sentry API, observed as a spike since 0.30.0 (CLI-F3, CLI-10):
per_pageexceeds API limit:listTransactionsandlistSpanspassed--limitdirectly asper_page. Values >100 were rejected by the API ("Invalid per_page value. Must be between 1 and 100."). Now caps atAPI_MAX_PER_PAGE(100) and auto-paginates when limit exceeds 100, matching the existingqueryEventspattern indiscover.ts.Open-ended date ranges produce incomplete params:
timeRangeToApiParams()returned onlystartor onlyendfor open-ended absolute ranges (e.g.,--period ">=2024-01-01"). The API requires both boundaries. Now fillsend=nowfor start-only ranges,start=end-90dfor end-only ranges. Fixes all consumers (traces, spans, explore).Fixes CLI-F3, CLI-10